package org.corey.share.db.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.corey.share.misc.SystemContext;

import com.google.appengine.api.datastore.Text;

@Entity
public class Article {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	private String title;
	@Temporal(TemporalType.TIME)
	private Date writeDate;
	@Temporal(TemporalType.TIME)
	private Date editedDate;
	private Long catogory;
	@Basic(fetch = FetchType.LAZY)
	private Text text;
	private boolean isTop;
	private Long type;
	@Basic(fetch = FetchType.LAZY)
	private String summary;
	private String keywords;
	private boolean isDeleted;
	private String respository;
	@Transient
	private String catogoryName;
	private int readCount;
	private List<Comment> comments = new ArrayList<Comment>();

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getWriteDate() {
		return writeDate;
	}

	public void setWriteDate(Date writeDate) {
		this.writeDate = writeDate;
	}

	public Date getEditedDate() {
		return editedDate;
	}

	public void setEditedDate(Date editedDate) {
		this.editedDate = editedDate;
	}

	public Long getCatogory() {
		return catogory;
	}

	public void setCatogory(Long catogory) {
		this.catogory = catogory;
	}

	public Text getText() {
		return text;
	}

	public void setText(Text text) {
		this.text = text;
	}

	public boolean getIsTop() {
		return isTop;
	}

	public void setIsTop(boolean isTop) {
		this.isTop = isTop;
	}

	public Long getType() {
		return type;
	}

	public void setType(Long type) {
		this.type = type;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public boolean getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(boolean isDeleted) {
		this.isDeleted = isDeleted;
	}

	public List<Comment> getComments() {
		return comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	public String getRespository() {
		return respository;
	}

	public void setRespository(String respository) {
		this.respository = respository;
	}

	public String getCatogoryName() {
		return catogoryName;
	}

	public void setCatogoryName(String catogoryName) {
		this.catogoryName = catogoryName;
	}

	public int getReadCount() {
		return this.readCount=SystemContext.getContext().getReadCount(this,this.readCount);
	}

	public void setReadCount(int readCount) {
		this.readCount = readCount;
	}

}
